package com.example.service.impl;

//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.mapper.CollectionMapper;
import com.example.pojo.entity.Collection;
import com.example.service.CollectionService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CollectionServiceImpl implements CollectionService{

    @Resource
    CollectionMapper collectionMapper;


    @Override
    public void insert(Collection collection) {
        collectionMapper.insert(collection);
    }

    @Override
    public void updateById(Collection collection) {
        collectionMapper.updateById(collection);
    }

    @Override
    public void removeById(Integer id) {

        collectionMapper.removeById(id);
    }

    @Override
    public void removeBatchByIds(List<Integer> ids) {

        for (Integer id : ids){
            collectionMapper.removeById(id);
        }
    }

    @Override
    public List<Collection> list() {
        List<Collection> list = collectionMapper.list();
        return list;
    }

    @Override
    public Collection getById(Integer id) {
        return collectionMapper.getById(id);
    }

    @Override
    public PageInfo<Collection> selectByPage(Integer pageNum, Integer pageSize, String name, String type, Integer showState) {
        PageHelper.startPage(pageNum, pageSize);
        List<Collection> list = collectionMapper.selectByPage(name, type, showState);
        return new PageInfo<>(list) ;
    }
}
